{include file="header.html"}
<script type="text/javascript">
    $(function () {
        $('#egg_form').validate({
            errorPlacement: function (error, element) {
                $(element).next('.field_notice').hide();
                $(element).after(error);
            },
            success: function (label) {
                label.addClass('right').text('OK!');
            },
            onkeyup: false,
            rules: {
                name: {
                    required: true
                },
                noun: {
                    required: true,
                    maxlength: 5,
                    digits: true
                },
                rate: {
                    required: true,
                    maxlength: 4
                }
            },
            messages: {
                name: {
                    required: '{$lang.notnull}'
                },
                noun: {
                    required: '{$lang.notnull}',
                    maxlength: '{$lang.noun_length}',
                    digits: '{$lang.digit}'
                },
                rate: {
                    required: '{$lang.notnull}',
                    maxlength: '{$lang.more_length}'
                }
            }
        });
    });
</script>
<div id="rightTop">
    <p>新增站内信</p>
    <ul class="subnav">
        <li><a class="btn1" href="index.php?app=message">{$lang.manage}</a></li>
        {if $egg.egg_id}
        <li><a class="btn1" href="index.php?app=message&amp;act=add">{$lang.add}</a></li>
        {else}
        <li><span>{$lang.add}</span></li>
        {/if}
    </ul>
</div>

<div class="info">
    <form method="post" enctype="multipart/form-data">
        <table class="infoTable">
            <tr>
                <th class="paddingT15">
                    发送内容:</th>
                <td class="paddingT15 wordSpacing5">
                    <textarea name="sendcontent"></textarea> 
                </td>
            </tr>
            <tr>
              <th class="paddingT15">
                   选择发送人:</th>
                <td class="paddingT15 wordSpacing5">
                    <button class="formbtn cart-add" type="button">选择</button>
                    <div class="choose_goods" style="padding-top:20px ">
                        <tr class="tatr1" id="after">
                              <td>用户名 | 真实姓名</td>
                              <td><span ectype="order_by" fieldname="email">邮箱</span></td>
                              <td>手机号</td>
                              <td>归属店铺</td>
                              <td>操作</td>
                        </tr>
                    <input id="user_id" name="user_id" style="display: none" >
                </td>
            </tr>
            </tr>
            <tr>
                <th></th>
                <td class="ptb20">
                    <input class="formbtn" type="submit" name="Submit" value="{$lang.submit}" />
                    <input class="formbtn" type="reset" name="Submit2" value="{$lang.reset}" />
                </td>
            </tr>
        </table>
    </form>
     <div class = "bg-model" style="position:absolute;top:0%;left:0%;display:none;background:rgba(0,0,0,0.3);width:100%;height:100%;position:fixed;z-index:9999">
            <iframe src="index.php?app=user&act=iframe" id="goods_page" width="90%" height="90%"></iframe>
        </div>
</div>
{include file="footer.html"}
<script type="text/javascript">
     $(".cart-add").click(function () {
        $("iframe").contents().find(".checkitem:checked");
        $("iframe").contents().find(".checkitem:checked").each(function () {
            $(this).removeAttr('checked');
        })
        $("iframe").contents().items = '';
        $(".bg-model").fadeTo(300,1)
        //隐藏窗体的滚动条
        $("body").css({ "overflow": "hidden" });
    });
     $("#enter").click(function () {
        var items = '';
        var name = '';
        $('.checkitem:checked').each(function(){
            items += this.value + ',';
            name += $(this).attr('attr-name') + ','
        });
        console.log()
        items = items.substr(0, (items.length - 1));
        name = name.substr(0, (name.length - 1));

        var items_arr = items.split(',');
        var name_arr = name.split(',');
        for(var i in items_arr){
            $(".choose_goods").append('' +
                '<label style="padding: 5px; border:1px solid #e3e3e3" name="goods" value="'+items_arr[i]+'">'+name_arr[i]+'</label><input type="checkbox" checked style="display: none" value="'+items_arr[i]+'" name="goods"><img style="margin-right: 10px;width:15px;height: 15px;" src="templates/style/images/close.gif" onclick="dropGoods(this' +
                ')" fieldname="mall_recommended" fieldid="{$goods.goods_id}" fieldvalue="1" title="{$lang.editable}"/>'
            );
        }
        $('#user_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
        $(".bg-model").hide();
        //显示窗体的滚动条
        $("body").css({ "overflow": "visible" });
    })
    function dropGoods(obj) {
        $(obj).parent().parent().remove();
        $(obj).remove()
        $('#user_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
    }
</script>
